﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Sample.Novel.Application.Contracts.Authors;
using Sample.Novel.Web.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace Sample.Novel.Web.Controllers
{
    public class HomeController : AbpController
    {
        private readonly IAuthorAppService authorAppService;

        public HomeController(IAuthorAppService authorAppService)
        {
            this.authorAppService = authorAppService;
        }

        public IActionResult Index() {
            return Redirect("/Swagger");
        }

        [HttpGet("GetAuthors")]
        public async Task<List<AuthorOutput>> GetList()
        {
            var authors = await authorAppService.GetAuthors();
            return authors;
        }

        [HttpPost("newAuthor")]
        public async Task<bool> NewAuthor(NewAuthorInput input){
            return await this.authorAppService.NewAuthor(input);
        }
    }
}
